package com.amsp.oa.oademo.controller;

import com.amsp.oa.oademo.entity.SpecialRewardApply;
import com.amsp.oa.oademo.service.SpecialRewardApplyService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/special-reward-apply")
@Api(tags = "专项奖励申请接口")
public class SpecialRewardApplyController {

    @Autowired
    private SpecialRewardApplyService specialRewardApplyService;

    @PostMapping("/save")
    @ApiOperation("保存专项奖励申请")
    public ResponseEntity<SpecialRewardApply> save(@RequestBody SpecialRewardApply specialRewardApply) {
        specialRewardApplyService.save(specialRewardApply);
        return ResponseEntity.ok(specialRewardApply);
    }

    @GetMapping("/list")
    @ApiOperation("获取专项奖励申请列表")
    public ResponseEntity<IPage<SpecialRewardApply>> list(
            @RequestParam(defaultValue = "1") Integer current,
            @RequestParam(defaultValue = "10") Integer size) {
        return ResponseEntity.ok(specialRewardApplyService.getPage(current, size));
    }

    @GetMapping("/{id}")
    @ApiOperation("获取专项奖励申请详情")
    public ResponseEntity<SpecialRewardApply> getById(@PathVariable Long id) {
        return ResponseEntity.ok(specialRewardApplyService.getById(id));
    }

    @DeleteMapping("/{id}")
    @ApiOperation("删除专项奖励申请")
    public ResponseEntity<Void> delete(@PathVariable Long id) {
        specialRewardApplyService.removeById(id);
        return ResponseEntity.ok().build();
    }
}